package com.freedom.ums.api.member.feign;

import com.freedom.common.core.result.CommonResult;
import com.freedom.ums.api.member.pojo.dto.MemberDTO;
import com.freedom.ums.api.member.pojo.dto.MemberLoginDTO;
import com.freedom.ums.api.member.pojo.dto.MemberAuthDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(name = "freedom-ums", contextId = "member", path = "/feign/member")
public interface MemberFeign {

    /**
     * 新增会员
     *
     * @param member
     * @return
     */
    @PostMapping("/internal/add")
    CommonResult<Integer> addMember(@RequestBody MemberDTO member);

    /**
     * 获取会员的 openid
     *
     * @return
     */
    @PostMapping("s/{memberId}/openid")
    CommonResult<String> getMemberOpenId(@PathVariable Integer memberId);

    /**
     * 根据openId获取会员认证信息
     *
     * @param openid
     * @return
     */
    @GetMapping("/openid/{openid}")
    CommonResult<MemberAuthDTO> loadUserByOpenId(@PathVariable String openid);

    /**
     * 根据手机号获取会员认证信息
     *
     * @param mobile
     * @return
     */
    @GetMapping("/mobile/{mobile}")
    CommonResult<MemberAuthDTO> findMemberByMobile(@PathVariable String mobile);


    /**
     * 根据手机号获取会员认证信息
     *
     * @param memberLoginDTO
     * @return
     */
    @PostMapping("/login/record")
    CommonResult<Boolean> memberLoginRecord(@RequestBody MemberLoginDTO memberLoginDTO);

    @GetMapping("/email/{email}")
    CommonResult<MemberAuthDTO> findMemberByEmail(@PathVariable String email);
}


